//package com.ebon.config.ds;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.baomidou.mybatisplus.entity.GlobalConfiguration;
//import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
//import com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean;
//import org.apache.ibatis.plugin.Interceptor;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//import javax.sql.DataSource;
//
///**
// * @Description:数据源
// * @Author:chenzhiye
// * @Date: Crated 2017/11/27
// */
//@Configuration
//@MapperScan(basePackages = DataSourceConfig.PACKAGE, sqlSessionFactoryRef = "zhhwSessionFactory")
//public class DataSourceConfig {
//
//  static final String PACKAGE = "com.fitns.user.dao.baseConfig";
//  private static final String mapperLocations = "classpath*:mybatis/**/*.xml";
//  private static final String typeAliasesPackage = "com.fitns.user.model";
//  //private static final String enumsPackage = "com.ebon.model.enums";
//
//  /*@Bean(name = "DataSource")
//  @Primary
//  @ConfigurationProperties(prefix = "custom.datasource.tms")
//  public DataSource dataSource() {
//    return new DruidDataSource();
//  }
//
//  @Bean(name = "tmsTransactionManager")
//  @Primary
//  public DataSourceTransactionManager transactionManager(
//      @Qualifier("tmsDataSource") DataSource dataSource) {
//    return new DataSourceTransactionManager(dataSource);
//  }
//*/
//  @Bean(name = "zhhwSessionFactory")
//  @Primary
//  public SqlSessionFactory sessionFactory(
//      @Qualifier("dataSource") DataSource dataSource) throws Exception {
//
//    //===1.mybatis-plus globalConfig配置
//    GlobalConfiguration globalConfig = new GlobalConfiguration();
//    // 字段的驼峰下划线转换
//    globalConfig.setDbColumnUnderline(true);
//
//    //===2.构造sessionFactory(mybatis-plus)
//    final MybatisSqlSessionFactoryBean sf = new MybatisSqlSessionFactoryBean();
//    sf.setDataSource(dataSource);
//    sf.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperLocations));
//    sf.setTypeAliasesPackage(typeAliasesPackage);
//    //sf.setTypeEnumsPackage(enumsPackage);
//    sf.setGlobalConfig(globalConfig);
//    // 分页插件
//    //sf.setPlugins(new Interceptor[]{new PaginationInterceptor()});
//
//    return sf.getObject();
//  }
//}